//
//  ViewController.m
//  11201
//
//  Created by student on 16/3/3.
//  Copyright © 2016年 NIIT. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,strong) NSArray *list;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.list=@[@"吃饭",@"睡觉",@"看书",@"吃屎",@"撒尿",@"玩游戏",@"吃饭",@"睡觉",@"看书",@"吃屎",@"撒尿",@"玩游戏",@"吃饭",@"睡觉",@"看书",@"吃屎",@"撒尿",@"玩游戏",@"吃饭",@"睡觉",@"看书",@"吃屎",@"撒尿",@"玩游戏",@"吃饭",@"睡觉",@"看书",@"吃屎",@"撒尿",@"玩游戏"];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.list.count;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"CELL"];
    cell.textLabel.text=self.list[indexPath.row];
    cell.imageView.image=[UIImage imageNamed:@"star"];
    cell.imageView.highlightedImage=[UIImage imageNamed:@"star2"];
    cell.detailTextLabel.text=[NSString stringWithFormat:@"干啥呢"];
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(nonnull NSIndexPath *)indexPath
{
    NSInteger row=indexPath.row;
    UIAlertController *alert=[UIAlertController alertControllerWithTitle:@"佳烨你要干啥" message:self.list[row] preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *action=[UIAlertAction actionWithTitle:@"是的" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action){
        [self dismissViewControllerAnimated:YES completion:nil];
    }];
    [alert addAction:action];
    [self presentViewController:alert animated:YES
                     completion:nil];
}
@end
